home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
TIPS
/
SWTIP
/
README.SWT
< prev
next >
Wrap
Text File
|
1994-07-02
|
10KB
|
257 lines
July 1994 Paul R. Santa-Maria (CIS 71674,422; GEnie PAUL.RSM)
This archive contains the source code from the book "Software Tools in
Pascal" by Brian W. Kernighan and P.J. Plauger, Addison-Wesley, 1981.
I have adapted and tested it for MS-DOS and Borland's Turbo Pascal 7
(TP7). Please inform me of any typographical errors you may find.
Instructions:
There are three files present:
README.SWT this file
SWTIP text file with all source files concatinated
INCLUDE.EXE executable for MS-DOS from the book
To extract all the files from SWTIP, compile and run UNCONCAT:
------------------ begin UNCONCAT.PAS --------------------------
program UNCONCAT;
{
Extract files from SWTIP:
open input file
open output file
while not end of input file
read line from input
if new file then
close old output file
open new input file
else
write line to output
end if
end while
close input file
close output file
}
var
IN_FILE, OUT_FILE : Text;
LINE : String[100];
INDEX : Integer;
begin
Assign(IN_FILE, 'SWTIP');
Reset(IN_FILE);
Assign(OUT_FILE, '');
Rewrite(OUT_FILE);
while (not Eof(IN_FILE)) do
begin
ReadLn(IN_FILE, LINE);
if ((LINE[1] = '{') and
(LINE[2] = '!')) then
begin
Close(OUT_FILE);
for INDEX := 1 to Length(LINE)-2 do
LINE[INDEX] := LINE[INDEX+2];
LINE[0] := Chr(Ord(LINE[0])-4);
Assign(OUT_FILE, LINE);
Rewrite(OUT_FILE);
Writeln;
Write(LINE, ' ');
end
else
begin
WriteLn(OUT_FILE, LINE);
Write('.');
end;
end;
Close(IN_FILE);
Close(OUT_FILE);
end.
------------------ end UNCONCAT.PAS ----------------------------
There are several types of files in SWTIP. Most of them are *.P that
are directly from the book. Fewer of them are *.I files which are the
master include files for each program in the book. There is one *.PAS
file that is a complete program listed in the book. Finally, there is
a COMPILER.INC file which contains all the compiler switches for the
programs. If you are not using an MS-DOS computer, you can break out
the routines by hand using a text editor. Each file is marked with a
{!filename.ext!} tag.
To recreate the sources for all the programs, run the INCL.BAT file:
------------------ begin INCL.BAT ------------------------------
INCLUDE < GLOBDEFS.I > GLOBDEFS.PAS
INCLUDE < PRIMS.I > PRIMS.PAS
INCLUDE < UTILITY.I > UTILITY.PAS
INCLUDE < CHARCNT.I > CHARCNT.PAS
INCLUDE < LINECNT.I > LINECNT.PAS
INCLUDE < WORDCNT.I > WORDCNT.PAS
INCLUDE < DETAB.I > DETAB.PAS
INCLUDE < ENTAB.I > ENTAB.PAS
INCLUDE < OVERSTRK.I > OVERSTRK.PAS
INCLUDE < COMPRESS.I > COMPRESS.PAS
INCLUDE < EXPAND.I > EXPAND.PAS
INCLUDE < ECHOZ.I > ECHOZ.PAS
INCLUDE < TRANSLIT.I > TRANSLIT.PAS
INCLUDE < COMPARE.I > COMPARE.PAS
INCLUDE < INCLUDEZ.I > INCLUDEZ.PAS
INCLUDE < CONCAT.I > CONCAT.PAS
INCLUDE < PRINTZ.I > PRINTZ.PAS
INCLUDE < MAKECOPY.I > MAKECOPY.PAS
INCLUDE < ARCHIVE.I > ARCHIVE.PAS
INCLUDE < SORTZ.I > SORTZ.PAS
INCLUDE < UNIQUE.I > UNIQUE.PAS
INCLUDE < KWIC.I > KWIC.PAS
INCLUDE < UNROTATE.I > UNROTATE.PAS
INCLUDE < FINDZ.I > FINDZ.PAS
INCLUDE < CHANGE.I > CHANGE.PAS
INCLUDE < EDIT1.I > EDIT1.PAS
INCLUDE < EDIT2.I > EDIT2.PAS
INCLUDE < FORMATZ.I > FORMATZ.PAS
INCLUDE < DEFINE.I > DEFINE.PAS
INCLUDE < MACRO.I > MACRO.PAS
------------------ end INCL.BAT --------------------------------
Although you can use the INCLUDE command on any file in SWTIP, only
the *.I files are set up to be complete and compilable programs.
Book errata:
'fsize.p' is needed but missing in 'archproc.p' (page 104).
'edprim.p' is missing yet used in 'editproc.p' (page 216).
'editvar.p' is implied but shown as part of 'edittype.p' (page 220).
'editvar.p' (see above) is missing vars shown in 'editvar.p' (page 216)
'seek.p' must be included in 'gettxt.p' (pages 220, 221).
'macproc.p' is needed but missing in 'macro.p' (page 289)
'islower.p' is missing yet used in 'utility.p' (page 323).
Miscellaneous:
The primitives are based on the UCB versions from the Appendix, but
they have been modified for TP7.
Type CHARACTER is changed from -1..127 to Byte. TP7 required this
because the ISxxxx functions used sets and and passing ENDFILE (-1) to
these functions caused the program to abort. I had to change both
ENDFILE (globdefs.p) and DITTO (findcons.p and editcons.p) from -1 to
255.
Where name collisions occurred between the book and TP7 or MS-DOS, I
added a suffix 'z' to the name. For example, 'string' became
'stringz'.
'globdefs' (page 325) defines ESCAPE = ATSIGN { @ } and this
definition is used in the routines 'esc' and 'dodash'. To avoid
confusion with the ASCII character ESCAPE I removed the definition
from 'globdefs' and added it back in as a constant in 'esc' and
'dodash'.
I changed all hard-coded constants from the form DQUOTE = 34 to the
form DQUOTE = ORD('"') and I removed the constants for the lower case
letters.
'settabs' (page 25) uses a tab size of 4. I changed it to 8.
I formatted the TP7 version with PF from Turbo Power's Turbo Analyst
to make all listings conform to a single layout standard in regards to
indentation and capitalization. The options for PF I used were '/C 33
/K+ /L+ /RL /SM /VU'. Information on Turbo Analyst can be found on
CompuServe's PCVENB forum, section 6.
I found the source code to the book on CompuServe's OS9 forum archived
using an OS9 compressor. I thank Ernest Withers Jr. (CIS 71545,1117)
who was kind enough to repackage it for MS-DOS for me. Following is
the original README file for that version; I preserved it even though
it is now obsolete.
README.V30 file from original archive on OS9 forum:
{readme.v30}
TURBTOOL.LBR DOCUMENTATION
This library contains the source from the book
"Software Tools in Pascal" by B.W. Kernighan and
P.J. Plauger, Addison-Wesley. It has been adapted
for Turbo Pascal.
How to Implement:
Compile SHELL.PAS with the CMD option
Execute SHELL
Accepts redirection, but not pipes.
Bill McGee, 613-828-9130
Notes: The version using TURBO is fast enough to make
this a useful set of tools for file manipulation.
------Further Modifications------
The primitives in this version are basically the UCSD Pascal versions
presented in the book, with modifications for Turbo Pascal.
This version has been modified for use under Turbo Pascal v. 3.0
under CP/M-86. There are no system dependent statements in the code
to the best of my knowledge, so it should work under MS-DOS as well.
The original version (typed in by Bill McGee) was set up for CP/M-80 and
used the CHAIN capability of Turbo Pascal. I have eliminated that
feature in favor of using INCLUDE files. There is not enough memory
available in a CP/M-80 system for this version, but one could modify
the include file list to eliminate unwanted features or to make more
than one version, (e.g. break out EDIT, FORMAT, and DEFINE).
There was really only one change required to the McGee's original to get
it to work with version 3.0. A readln(TRM) had to be added in the
subroutine GETKBD. The change to CP/M-86 required replacing all calls
to the procedure BDOS(0,0) with HALT. This change works with the CP/M-80
version of Turbo Pascal v. 3.0 as well. Thus, as anyone can see, all of
the hard work was done by Bill.
(Adaption to version 3.0 of Turbo Pascal by Jim Potter, (505) 662-5804.)
Please note that this is copyright software. The following notice has
been included with each file and should not be removed.
+-------------------------------------------------------------------------+
| Copyright (c) 1981 |
| By: Bell Telephone Laboratories, Inc. and |
| Whitesmith's Ltd., |
| |
| This software is derived from the book |
| "Software Tools in Pascal", by |
| Brian W. Kernighan and P. J. Plauger |
| Addison-Wesley, 1981 |
| ISBN 0-201-10342-7 |
| |
| Right is hereby granted to freely distribute or duplicate this |
| software, providing distribution or duplication is not for profit |
| or other commercial gain and that this copyright notice remains |
| intact. |
+-------------------------------------------------------------------------+
===========================================================================
Title: "Software Tools in Pascal" source code
Keys: SOFTWARE TOOLS PASCAL BOOK SOURCE KERNIGHAN PLAUGER
This archive contains the source code from the book "Software Tools in
Pascal" by Brian W. Kernighan and P.J. Plauger, Addison-Wesley, 1981.
It has been adapted for MS-DOS and Borland's Turbo Pascal 7.0.